using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class JobSeekers_other : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
             WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        
        if(!IsPostBack)
        {
            ShowOtherInfo();
        }
    }
    void ShowOtherInfo()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);
        cls.CommandText = "select * from " +
        " tblJSOthers where UserID='"
        + Session["jsuserid"] + "'";
        DataRow dataRow =
        cls.GetDataRow();
        if (dataRow !=null)
        {
            txtStrength.Text = dataRow[1].ToString();
            txtWeekness.Text = dataRow[2].ToString();
            txtHobbies.Text = dataRow[3].ToString();
            txtFamily.Text = dataRow[4].ToString();
            txtReference.Text = dataRow[5].ToString();  
            btnComplete.Text = "Update";          
        }
        else
            btnComplete.Text = "Save";
    }

    protected void btnComplete_Click(object sender, EventArgs e)
    {
        if(txtStrength.Text!="" || 
        txtStrength.Text!="" || 
        txtWeekness.Text!="" ||        
        txtHobbies.Text!="" ||
        txtFamily.Text!="" ||
        txtReference.Text!="")
        {
            RecruitVietnam cls = new RecruitVietnam();
            cls.ConnectionString = connectionString;
            if (cls.AddNewOrUpdateOthers(
            ((btnComplete.Text == "Save")?true:false),
             Convert.ToString(Session["jsuserid"]),
            txtStrength.Text, txtWeekness.Text,        
            txtHobbies.Text,
            txtFamily.Text,
            txtReference.Text))                
            {                 
                Response.Redirect("thankyou.aspx");
            }
            else
                literalError.Text = "Error: " 
                + cls.ErrorMessage;            
        }
        else
        {            
            Response.Redirect("thankyou.aspx");
        }
    }
}
